﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Trackr.DataAccess
{
	public class DataAccessConfig : ConfigurationSection
	{
		[ConfigurationProperty("default", DefaultValue = "Trackr.DataAccess.FakeTrackrDataStore, Trackr.DataAccess", IsRequired = true)]
		public string Default
		{
			get
			{
				return this["default"] as string;
			}
		}
		[ConfigurationProperty("", IsRequired = true, IsDefaultCollection = true)]
		public DataAccessConfigElementCollection Instances
		{
			get { return (DataAccessConfigElementCollection)this[""]; }
			set { this[""] = value; }
		}

	}
	public class DataAccessConfigElementCollection : ConfigurationElementCollection
	{
		public DataAccessConfigElement this[int index]
		{
			get
			{
				return base.BaseGet(index) as DataAccessConfigElement;
			}
		}
		public DataAccessConfigElement this[string name]
		{
			get
			{
				return base.BaseGet(name) as DataAccessConfigElement;
			}
		}

		protected override ConfigurationElement CreateNewElement()
		{
			return new DataAccessConfigElement();
		}

		protected override object GetElementKey(ConfigurationElement element)
		{
			return ((DataAccessConfigElement)element).Name;
		}
	}
	public class DataAccessConfigElement : ConfigurationElement
	{
		[ConfigurationProperty("name", IsRequired = true)]
		public string Name
		{
			get
			{
				return this["name"] as string;
			}
		}

		[ConfigurationProperty("type", IsRequired = true)]
		public string Type
		{
			get
			{
				return this["type"] as string;
			}
		}
	}
}
